import Taro from '@tarojs/taro'
import { View, Text, Form, Input, Button } from "@tarojs/components";
import { AtModal, AtModalHeader, AtModalContent, AtModalAction, AtInput } from 'taro-ui';
import { useEffect, useState } from 'react';
import './shopdata.scss'

const Shopdata = () => {

        // 所属拼团点：
        const [point, setpoint] = useState('社区名称')
        //门店名称：
        const [shopname, setshopname] = useState('鲜丰水果')
        //社会统一信用代码：
        const [shehuiid, setshehuiid] = useState('330282608040519')
        //团长：
        const [headman, setheadman] = useState('李小明')
        //联系电话：
        const [phone, setphone] = useState('1855555555')
        //身份证号：
        const [sfz, setsfz] = useState('5111321985055555555')
        //门店地址：
        const [address, setaddress] = useState('北京市XXXXXXXXXXX')
        //邀请码：
        const [code, setcode] = useState('GKORN')
        //保存表单数据
        const [zhi, Setzhi] = useState()

        //模态框
        const [isOpened, SetMaodl] = useState(false)
        const [canOpened, SetMaodlcan] = useState(false)



        //获取表单值
        const Submit = (ev) => {
                console.log(ev.detail.value)

                Setzhi(ev.detail.value)
        }

        //传送值
        const submit = () => {
                SetMaodlcan(false)
                console.log('1', zhi)
        }

        //打开模态框
        const open = () => {
                let i = 2
                if (i == 1) {
                        SetMaodl(true)
                } else {
                        SetMaodlcan(true)
                }
        }

        /* useEffect(() => {
                console.log(code)
        }, [code]) */


        return (
                <>
                        <Form onSubmit={Submit}>
                                <View className='input'>
                                        <View>所属拼团点：</View>
                                        <AtInput name='setpoint' type='text' value={point} onChange={(v) => { setpoint(v) }} />
                                </View>

                                <View className='input'>
                                        <View>门店名称：</View>
                                        <AtInput name='setshopname' type='text' value={shopname} onChange={(v) => { setshopname(v) }} />
                                </View>
                                <View className='input'>
                                        <View>社会统一信用代码：</View>
                                        <AtInput name='setshehuiid' type='number' value={shehuiid} onChange={(v) => { setshehuiid(v) }} />
                                </View>
                                <View className='input'>
                                        <View>团长：</View>
                                        <AtInput name='setheadman' type='text' value={headman} onChange={(v) => { setheadman(v) }} />
                                </View>
                                <View className='input'>
                                        <View>联系电话：</View>
                                        <AtInput name='setphone' type='number' value={phone} onChange={(v) => { setphone(v) }} />
                                </View>
                                <View className='input'>
                                        <View>身份证号：</View>
                                        <AtInput name='setsfz' type='idcard' value={sfz} onChange={(v) => { setsfz(v) }} />
                                </View>
                                <View className='input'>
                                        <View>门店地址：</View>
                                        <AtInput name='setaddress' type='text' value={address} onChange={(v) => { setaddress(v) }} />
                                </View>
                                <View className='input'>
                                        <View>邀请码：</View>
                                        <AtInput name='setcode' type='text' value={code} onChange={(v) => { setcode(v) }} />
                                </View>
                                <View className='button'>
                                        <Button formType='submit' onClick={open}>申请修改资料</Button>
                                </View>
                        </Form>

                        <AtModal isOpened={isOpened}>
                                <AtModalHeader>提示</AtModalHeader>
                                <AtModalContent>
                                        <View className='model'>
                                                <View>店铺当前有正在拼团的商品</View>
                                                <View>请结束后再尝试申请</View>
                                        </View>

                                </AtModalContent>
                                <AtModalAction> <Button onClick={() => { SetMaodl(false) }}>知道了</Button></AtModalAction>
                        </AtModal>

                        <AtModal isOpened={canOpened}>
                                <AtModalHeader>提示</AtModalHeader>
                                <AtModalContent>
                                        <View className='model'>
                                                <View>确认资料有变更需要重新提交审核吗</View>
                                                <View>进入审核后店铺无法发起拼团</View>
                                        </View>
                                </AtModalContent>

                                <AtModalAction> <Button onClick={() => { SetMaodlcan(false) }}>不，谢谢</Button><Button onClick={submit}>确认申请</Button></AtModalAction>
                        </AtModal>


                </>

        )

}


export default Shopdata;

